package com.gdssoft.core.datasource;

import java.util.ArrayList;
import java.util.List;

import com.gdssoft.core.util.DESUtil;

/**
 * 系统默认对数据库链接字符串等数据进行加密以防止帐密泄漏，<code>DecodeBasicDataSource</code> 扩展
 * <code>BasicDataSource</code>实现解密这些关键数据
 * 
 * @author F3221430
 * 
 */
public class DecodeBasicDataSource extends
		org.apache.commons.dbcp.BasicDataSource {

	@Override
	public synchronized void setPassword(String password) {

		DESUtil desUtil = new DESUtil("gds+88");
		String decodePassword = desUtil.decrypt(password);
		super.setPassword(decodePassword);
	}
	
	public static void main(String[] args) {
		//TODO big bug UnDecryptException
		String sourceString = "pda123";
		DESUtil desUtil = new DESUtil("gds+88");
		String cryptograph = desUtil.encrypt(sourceString);
		System.out.println(cryptograph);
		System.out.println(desUtil.decrypt(cryptograph));
	}
}
